Skip to content

Conversation

@dimitrijjedich
Copy link
Collaborator

🚀 Add BucketSort Algorithm

🗒️ General

This PR introduces the Bucket Sort algorithm to the project Bucket Sort is a non-comparison-based sorting algorithm that distributes elements into buckets and sorts them individually.


💡 Idea Behind Bucket Sort

Bucket Sort works by dividing the input data into several buckets and sorting each bucket individually. Finally, the sorted buckets are concatenated to produce the sorted output.

🤔 Details

  1. Bucket Division:
    The algorithm takes the square root of the number of values as bucket ranges.

  2. Bucket Distribution:
    Elements are distributed into appropriate buckets based on their value.

  3. Sorting Individual Buckets:
    Each bucket is sorted using an sorting algorithm determined by the provided class in the property (GnomeSort).

  4. Concatenation:
    The sorted buckets are merged into the result array which is returned.


📉 Downsides of Bucket Sort

I am not sure if this should be considered as a sorting algorithm itself, because it does not acually sort the values but only distributes them into smaller buckets that then need to be sorted.


🛠 Implementation Note:

This, while not a realy sorting algorithm, would allow for a system, that determines, which sorting algorithm should be used on a array and use it accordingly. The implementations was done so that the used algorithm for the sorting can be replaced by changing the provided class but can be extended to have a more dynamic approach. This would however need to have some sort of decision system on which algorithm to use based on the input.

@dimitrijjedich dimitrijjedich self-assigned this Dec 26, 2024
@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants